web/src/pages/[...listing].astro
567 lines · 14892 bytes
1---
2
3import Layout from '@layouts/Layout.astro';
4import ServiceList from '@components/things/ServiceList.astro';
5import Comments from '@components/things/Comments.svelte';
6import GitHubDetailedInfo from '@components/things/GitHubDetailedInfo.astro';
7import PrivacyPolicyDetails from '@components/things/PrivacyPolicyDetails.astro';
8import WebsiteDetailedInfo from '@components/things/WebsiteDetailedInfo.astro';
9import DataActions from '@components/things/DataActions.svelte';
10import type { AwesomePrivacy, Section, Service } from '../types/Service';
11import { fetchData, slugify } from '@utils/fetch-data';
12import { fetchGitHubStats } from '@utils/fetch-repo-info';
13import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy';
14import { fetchWebsiteInfo } from '@utils/fetch-website-info';
15import { parseMarkdown, formatLink } from '@utils/parse-markdown';
16import FontAwesome from '@components/form/FontAwesome.svelte';
17import Button from '@components/form/Button.astro';
18
19interface Props extends Service {
20 slug: string;
21 parentSection: Section;
22 categoryName: string;
23}
24
25const {
26 name,
27 description,
28 url,
29 github,
30 tosdrId,
31 icon,
32 followWith,
33 securityAudited,
34 openSource,
35 acceptsCrypto,
36 parentSection,
37 categoryName,
38} = Astro.props;
39
40
41/**
42 * Make a list of keywords, for the <meta keywords> tag
43 */
44const makeKeyWordTag = () => {
45 const keywords: string[] = [];
46 keywords.push(`free and open source ${parentSection.name} software`);
47 keywords.push(`private ${parentSection.name} comparison`);
48 (parentSection.alternativeTo || []).forEach((alt: string) => {
49 keywords.push(`privacy-respecting ${alt} alternative`);
50 keywords.push(`free open source ${alt} alternative`);
51 });
52 (parentSection.services || []).forEach((serv: Service) => {
53 keywords.push(serv.name);
54 });
55 keywords.push('ad free');
56 keywords.push('open source software');
57 keywords.push('privacy respecting apps');
58 return keywords.join(', ');
59};
60
61/**
62 * Make a page title
63 */
64const makePageTitle = () => {
65 return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`;
66};
67
68/**
69 * Make a string page intro, for the description tag
70 */
71const makeDescriptionTag = () => {
72 return `Compare ${name} and other ${parentSection.name} at Awesome Privacy\n`
73 + description
74 + '\nAll this, and much more at Awesome Privacy, '
75 + 'the free and open source list of private software alternatives.';
76};
77
78// Return a list of Services, except for the currtent one
79const filterServices = () => {
80 return parentSection.services.filter((service: Service) => service.name !== name);
81};
82
83export async function getStaticPaths() {
84 const pages = await fetchData().then((data) => {
85 const results: Array<Props> = [];
86 if (!data || !data.categories) return results;
87 (data as AwesomePrivacy).categories.forEach((category) => {
88 category.sections.forEach((section) => {
89 const services = (section.services || []).map((service) => {
90 return {
91 slug: `${slugify(category.name)}/${slugify(section.name)}/${slugify(service.name)}`,
92 parentSection: section,
93 categoryName: category.name,
94 ...service,
95 };
96 });
97 results.push(...services);
98 });
99
100 });
101 return results;
102 });
103
104 return pages.map((props: Props) => {
105 return {params: { listing: props.slug }, props };
106 });
107}
108
109const makePaginationLinks = () => {
110 const allServices = parentSection.services || [];
111 const index = allServices.findIndex(item => item.name === name);
112 const previousItem = index > 0 ? allServices[index - 1].name : null;
113 const nextItem = index < allServices.length - 1 ? allServices[index + 1].name : null;
114 return { previous: previousItem, next: nextItem };
115};
116
117const { previous, next } = makePaginationLinks();
118
119
120const ignoredSites = ['github.gom', 'wikipedia.'];
121
122// Fetch detailed data about the services GitHub repo, privacy policy and website
123const githubData = github ? await fetchGitHubStats(github) : null;
124const privacyData = tosdrId ? await fetchTosdrPrivacy(tosdrId) : null;
125const websiteData = (url && !ignoredSites.some(ignoredSite => url.includes(ignoredSite))) ? await fetchWebsiteInfo(url) : null;
126
127const getApiEndpoint = () => {
128 return `https://api.awesome-privacy.xyz/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`;
129}
130
131---
132
133<Layout title={makePageTitle()} keywords={makeKeyWordTag()} description={makeDescriptionTag()} >
134 <main>
135 <section>
136 <div class="service-head">
137 <h2>{name}</h2>
138 <span class="url-wrap">
139 <a class="service-url" href={url}>{formatLink(url)}</a>
140 <span class="follow-with">{followWith}</span>
141 </span>
142 </div>
143 <div class="breadcrumbs">
144 <span>
145 <a href="/">Awesome Privacy</a>
146 ➔ <a href={`/${slugify(categoryName)}`}>{categoryName}</a>
147 ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}>{parentSection.name}</a>
148 ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`}>{name}</a>
149 </span>
150 </div>
151 <div class="intro">
152 <img
153 width="60"
154 height="60"
155 loading="lazy"
156 decoding="async"
157 class="service-icon"
158 alt={`${name} Icon`}
159 data-service-url={formatLink(url)}
160 src={icon || `https://icon.horse/icon/${formatLink(url)}`}
161 />
162 <div>
163 <p class="description" set:html={parseMarkdown(description)}></p>
164 <ul>
165 { url && (
166 <li>
167 <b>Homepage:</b>
168 <a href={url}>{formatLink(url)}</a>
169 </li>
170 )}
171 { github && (
172 <li>
173 <b>GitHub:</b>
174 <a href={`https://github.com/${github}`}>github.com/{github}</a>
175 </li>
176 )}
177 { tosdrId && (
178 <li>
179 <b>Privacy:</b>
180 <a href={`https://tosdr.org/en/service/${tosdrId}`}>{`tosdr.org/en/service/${tosdrId}`}</a>
181 </li>
182 )}
183 { url && (
184 <li>
185 <b>Web info:</b>
186 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url).split('/')[0]}`}</a>
187 </li>
188 )}
189 </ul>
190 </div>
191 </div>
192 <div class="highlights">
193 { securityAudited && (
194 <span class="meta-item great" title={`${name} has been security audited by an accredited auditor, with results published publicly`}>
195 <FontAwesome iconName="securityAudited" /> Security Audited
196 </span>
197 )}
198 { acceptsCrypto && (
199 <span class="meta-item great" title={`${name} accepts anonymous payment methods`}>
200 <FontAwesome iconName="cryptoAccepted" /> Crypto Payments Accepted
201 </span>
202 )}
203 { securityAudited === false && (
204 <span class="meta-item warning" title={`${name} has not been audited`}>
205 <FontAwesome iconName="notSecurityAudited" /> No Security Audit
206 </span>
207 )}
208 { (openSource === false) && (
209 <span class="warning">
210 <FontAwesome iconName="closedSource" />
211 Not Open Source
212 </span>
213 )}
214 { openSource || (github && openSource !== false) ? (
215 <span class="meta-item great" title={`${name} is open source`}>
216 <FontAwesome iconName="openSource" /> Open Source
217 </span>
218 ) : null }
219 </div>
220 </section>
221 { privacyData && (
222 <section>
223 <h3>{name} Privacy Policy</h3>
224 <PrivacyPolicyDetails privacyData={privacyData} />
225 </section>
226 )}
227 { github && githubData && (
228 <section class="github-wrap">
229 <h3>{name} Source Code</h3>
230 <GitHubDetailedInfo gitHubData={githubData} repo={github} />
231 </section>
232 )}
233
234 { websiteData && (
235 <section>
236 <h3>{name} Website</h3>
237 <WebsiteDetailedInfo url={url} websiteInfo={websiteData} />
238 </section>
239 )}
240 <section>
241 <h3>{name} Reviews</h3>
242 <Comments client:visible />
243 </section>
244 <section>
245 <h3>More {parentSection.name}</h3>
246 <ServiceList
247 services={filterServices()}
248 subHeading={true}
249 noGitHubMetrics={true}
250 buttonLink={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}
251 categoryName={categoryName}
252 sectionName={parentSection.name}
253 />
254 </section>
255 <section>
256 <h3>About the Data: {name}</h3>
257 <DataActions client:load categoryName={categoryName} sectionName={parentSection.name} serviceName={name} />
258 <h4>API</h4>
259 <p>
260 You can access {name}'s data programmatically via our API.
261 Simply make a <code>GET</code> request to:
262 </p>
263 <pre><a href={getApiEndpoint()}><code>{getApiEndpoint()}</code></a></pre>
264 <p>
265 The REST API is free, no-auth and CORS-enabled.
266 To learn more, view the <a href="/api/docs">Swagger Docs</a> or read the <a href="/about#our-api">API Usage Guide</a>.
267 </p>
268
269 <h4>About the Data</h4>
270 <p>
271 Beyond the user-submitted YAML you see above, we also augment each listing with
272 additional data dynamically fetched from several sources.
273 To learn more about where the rest of data included in this page comes from,
274 and how it is computed,
275 see the <a href="/about#our-data">About the Data</a> section of our About page.
276 </p>
277 </section>
278
279 <div class="pagination-navigation">
280 { previous ? (
281 <Button url={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(previous)}`}>
282 <span>← Previous</span>
283 <p>{previous}</p>
284 </Button>
285 ) : <p class="nothing"></p>}
286 <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`} class="go-to-category">
287 View {parentSection.name} ({(parentSection.services || []).length})
288 </a>
289 { next && (
290 <Button url={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(next)}`}>
291 <span>Next →</span>
292 <p>{next}</p>
293 </Button>
294 )}
295 </div>
296 </main>
297</Layout>
298
299<style lang="scss">
300
301main {
302 margin: 2rem auto;
303 padding: 1rem;
304 width: 1000px;
305 max-width: calc(100% - 5rem);
306 position: relative;
307 @media(max-width: 768px) {
308 max-width: 95%;
309 padding: 0.5rem;
310 margin: 0 auto;
311 }
312}
313
314section {
315 margin: 1rem 0 4rem 0;
316 padding: 1rem;
317 min-height: 8rem;
318 position: relative;
319 border: 2px solid var(--foreground);
320 box-shadow: 6px 6px 0 var(--foreground);
321 background: var(--accent-fg);
322
323}
324
325p {
326 margin: 0.25rem 0 0.5rem 0;
327}
328
329h3 {
330 font-size: 2rem;
331 margin: -2rem 0 1rem -2rem;
332 box-shadow: 6px 6px 0 var(--foreground);
333 background: var(--accent);
334 color: var(--accent-fg);
335 width: fit-content;
336 padding: 0.25rem 0.5rem;
337 @media(max-width: 768px) {
338 margin: -2rem auto 2rem auto;
339 }
340 }
341
342.service-head {
343 h2 {
344 font-size: 3rem;
345 margin: 0;
346 @media(max-width: 768px) {
347 text-align: center;
348 }
349 }
350 .url-wrap {
351 display: flex;
352 align-items: center;
353 gap: 0.5rem;
354 a {
355 font-size: 1.2rem;
356 }
357 .follow-with {
358 font-style: italic;
359 opacity: 0.6;
360 }
361 @media(max-width: 768px) {
362 flex-direction: column;
363 }
364 }
365
366}
367
368.breadcrumbs {
369 opacity: 0.5;
370 font-size: 0.8rem;
371 position: absolute;
372 right: 1rem;
373 top: 1rem;
374 a {
375 color: var(--foreground);
376 transition: all 0.15s ease-in-out;
377
378 &:hover {
379 color: var(--accent);
380 }
381 }
382 @media(max-width: 768px) {
383 display: none;
384 }
385}
386
387h4 {
388 font-size: 1.4rem;
389 margin-bottom: 0;
390}
391
392.intro {
393 font-size: 1.2rem;
394 font-style: italic;
395 opacity: 0.9;
396 display: flex;
397 gap: 0.5rem;
398 @media(max-width: 768px) {
399 flex-direction: column;
400 }
401 .service-icon {
402 border-radius: var(--curve-md);
403 margin-top: 1rem;
404 @media(max-width: 768px) {
405 margin: 1rem auto 0 auto;
406 }
407 }
408 ul {
409 padding-left: 1rem;
410 list-style: circle;
411 font-style: normal;
412 font-size: 1rem;
413 margin-top: 0;
414 b {
415 font-size: 1rem;
416 font-weight: 400;
417 min-width: 85px;
418 display: inline-block;
419 @media(max-width: 768px) {
420 width: auto;
421 display: block;
422 }
423 }
424 }
425}
426
427.pagination-navigation {
428 display: flex;
429 justify-content: space-between;
430 align-items: center;
431 padding: 1rem 0;
432 :global(.button) {
433 min-width: 120px;
434 width: fit-content;
435 padding: 0.25rem 1rem;
436 text-align: right;
437 &:first-child { text-align: left; }
438 p {
439 margin: 0;
440 font-weight: normal;
441 font-size: 1rem;
442 }
443 span {
444 font-size: 0.8rem;
445 }
446
447 }
448 .nothing {
449 width: 120px;
450 }
451 .go-to-category {
452 color: var(--foreground);
453 font-size: 0.8rem;
454 opacity: 0.5;
455 @media (max-width: 768px) {
456 display: none;
457 }
458 }
459}
460
461
462
463.further-info, .notable-mentions, .word-of-warning {
464 h3 {
465 font-size: 1.4rem;
466 margin: 1rem 0;
467 }
468 :global(p) {
469 font-size: 0.9rem;
470 opacity: 0.7;
471 :global(strong) {
472 font-weight: 500;
473 }
474 :global(a) {
475 color: var(--foreground);
476 transition: all 0.15s ease-in-out;
477 &:hover {
478 color: var(--accent);
479 }
480 }
481 }
482 :global(strong) {
483 font-weight: 500;
484 }
485 :global(h4) {
486 font-size: 1.2rem;
487 margin: 0.5rem 0 0 0;
488 }
489 :global(ul) {
490 list-style: circle;
491 padding-left: 1rem;
492 font-size: 0.9rem;
493 opacity: 0.7;
494 li {
495 margin-bottom: 0.25rem;
496 :global(p) {
497 display: inline;
498 }
499 }
500 }
501}
502
503pre {
504 a {
505 text-decoration: none;
506 color: var(--foreground);
507 code {
508 background: #acabb782;
509 padding: 0.2rem 0.4rem;
510 border-radius: var(--curve-sm);
511 font-family: Courier New;
512 font-size: 0.9rem;
513 @media(max-width: 768px) {
514 white-space: break-spaces;
515 }
516 }
517 }
518}
519
520.highlights {
521 display: flex;
522 gap: 1rem;
523 flex-wrap: wrap;
524 align-items: center;
525 justify-content: end;
526
527 .meta-item, .warning {
528 display: flex;
529 align-items: center;
530 // justify-content: center;
531 gap: 0.25rem;
532 opacity: 0.6;
533 font-size: 0.9rem;
534 padding: 0.5rem 0;
535 :global(svg) {
536 color: var(--foreground);
537 width: 1.2rem;
538 height: 1.2rem;
539 }
540 a {
541 text-decoration: none;
542 color: var(--foreground);
543 display: flex;
544 gap: 0.25rem;
545 &:hover {
546 color: var(--accent-3);
547 :global(svg) {
548 color: var(--accent-3);
549 }
550 }
551 }
552 }
553 .warning {
554 color: var(--danger);
555 :global(svg) {
556 color: var(--danger);
557 }
558 }
559 .great {
560 color: #007930; // var(--success);
561 :global(svg) {
562 color: #007930; // var(--success);
563 }
564 }
565}
566
567</style>